package com.example.controller;

import com.example.pojo.Result;
import com.example.pojo.maturityDataPojo;
import com.example.pojo.outputFileDataPojo;
import com.example.service.maturityManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * ClassName:maturityManageController
 * Description:
 *成熟度管理板块
 * @Author 赵永峰
 * @Create 2025/3/11 16:04
 * @Version 1.0
 */
@RestController
public class maturityManageController {
    @Autowired
    private maturityManageService maturityManageService;
    //辅助函数：根据字段名，去搜索等于这个字段数据的所有数据,多个字段，用的是并且。现在写好的是根据一个字段搜索,并且赋值给成熟度管理的总表
    @PostMapping("/inquiryFiledSeveralAndMaturityManage")
    public Result inquiryFiledSeveralAndMaturityManage(@RequestBody Map<String,Object> map){
        List<maturityDataPojo> pojos=maturityManageService.inquiryFiledSeveralAnd(map);
        return Result.success(pojos);
    }
    //插入一条项目数据，可以用在所以的插入一行中，已经设置了所有的字段
    @PostMapping("/insertProjectMaturityManage")
    public Result insertProjectMaturityManage(@RequestBody maturityDataPojo maturityDataPojo){
        maturityManageService.insertOne(maturityDataPojo);
        return Result.success("插入成功");
    }
    //辅助函数：根据Id，修改一个字段的值，Id可能是多个，后端进行分割，组合，分割符“/”.需要传入的是editOneFieldMaturitData数据
    @PostMapping("/editOneFieldMaturityManage")
    public Result editOneFieldMaturityManage(@RequestBody Map<String,Object> map){
        maturityManageService.editOneFieldSeveralId(map);
        return Result.success("修改成功");

    }
    //辅助函数：对输出物部分插入一行数据，向后端发送数据
    @PostMapping("/insetOneOutputFileMaturityManage")
    public Result insetOneOutputFileMaturityManage(@RequestBody outputFileDataPojo pojo ){
        maturityManageService.insetOneOutputFile(pojo);
        return Result.success("插入成功");
    }
    //辅助函数：对输出物所有的信息筛选出来
    @PostMapping("/inquiryOutputFileAllMaturityManage")
    public Result inquiryOutputFileAllMaturityManage(){
        List<outputFileDataPojo> pojos= maturityManageService.inquiryOutputFileAll();
        return Result.success(pojos);
    }
}
